const $ = el => document.querySelector(el)
const gets = el => [...document.querySelectorAll(el)]

let btn = $('.box button')
let inps = gets('input')
let p = gets('p')
console.log(inps)
    inps.forEach((input,i)=>{
        input.addEventListener('focus',e=>{
                input.value.trim() === ''? p[i].classList.add('show') : p[i].classList.remove('show')
            })
            input.addEventListener('input',e=>{
                input.value.trim() === ''? p[i].classList.add('show') : p[i].classList.remove('show')
            })
        })
        btn.addEventListener('click',e=>{
            let val1 = $('.name input').value.trim()
            let val2 = $('.pwd input').value.trim()
            if(val1 === '') return p[0].classList.add('show')
            if(val2 === '') return p[1].classList.add('show')
            location.href = './详情页.html'
        })